from django.db import models

# Create your models here.
from competition.models import CompetitionSeason
from school.models import School
import django.utils.timezone as timezone

class Student(models.Model):
    PAYMENT_STATUS = [
        (0,'未缴费'),
        (1,'已缴费')
    ]
    GENDER = [
        (0, '男'),
        (1, '女')
    ]
    student_name = models.CharField(max_length=125, verbose_name='学生名字', help_text='学生名字',db_index=True)

    contact_name = models.CharField(max_length=40, verbose_name='联系人姓名', null=True, blank=True, default='', help_text='联系人姓名')
    contact_phone = models.CharField(max_length=11, verbose_name='联系人电话', null=True, blank=True, default='', help_text='联系人电话')

    competition_season = models.ForeignKey(CompetitionSeason,default=1,
                                           verbose_name='所属赛季',help_text='所属赛季',on_delete=models.CASCADE)
    gender = models.IntegerField(choices=GENDER,default=0,verbose_name='性别', help_text='性别',db_index=True)
    ID_number = models.CharField(max_length=18,verbose_name='身份证号',help_text='身份证号',db_index=True)
    birth_date = models.DateField(verbose_name='出生日期',help_text='出生日期',db_index=True)
    registration_date = models.DateField(verbose_name='报名日期',help_text='报名日期',db_index=True,blank=True,null=True)
    payment_status = models.IntegerField(choices=PAYMENT_STATUS,default=0,db_index=True,
                                         verbose_name='付款状态', help_text='付款状态'
                                         )
    payment_amount = models.DecimalField(max_digits=5,decimal_places=2,default=0,blank=True,null=True,
                                         verbose_name='付款金额', help_text='付款金额'
                                         )
    school = models.ForeignKey(School,on_delete=models.CASCADE,verbose_name='所属校区',help_text='所属校区',db_index=True)
    create_time = models.DateTimeField(verbose_name='创建日期',help_text='创建日期',default=timezone.now)



    class Meta:
        verbose_name = "学员"
        verbose_name_plural = verbose_name
        ordering = ['-id']

    def __str__(self):
        return self.student_name